﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;

namespace EasyCode.Web.UI
{
    public partial class Message : System.Web.UI.UserControl
    {
        #region Consts
        const string ERROR_CSS = "error_msg";
        const string SUCCESS_CSS = "success_msg";
        const string NOTICE_CSS = "notice_msg";
        const string INFO_CSS = "info_msg";

        #endregion
        #region Helpers
        private void thisShowMessage(string css, string message)
        {
            Literal_Message.Text = string.Format("<div class='{0}'>{1}</div>", css, message);
            UpdatePanel_Message.Update();
        }
        #endregion

        #region Methods
        public void SetError(string message)
        {
            thisShowMessage(ERROR_CSS, message);
        }

        public void SetSuccess(string message)
        {
            thisShowMessage(SUCCESS_CSS, message);
        }

        public void SetMessage(string message)
        {
            thisShowMessage(INFO_CSS, message);
        } 
        #endregion

        #region Commands
        protected void Page_Load(object sender, EventArgs e)
        {
            Literal_Message.Text = string.Empty;
            UpdatePanel_Message.Update();
        } 
        #endregion
    }
}